#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion

using UnityEngine;
using System.Collections.Generic;

namespace Neatly.Tween
{
    public class EffectTweenObjectPool<T> where T : new()
    {
        List<T> pool = new List<T>();
        public T Create()
        {
            if (pool.Count <= 0)
            {
                return new T();
            }
            T obj = pool[pool.Count - 1];
            pool.RemoveAt(pool.Count - 1);
            return obj;
        }
        public void Recycle(T obj)
        {
            pool.Add(obj);
        }
        public int Count { get { return pool.Count; } }
    }

    public abstract class EffectTweenObjectBase
    {
        public GameObject gameObject;
        public float _dt;

        public virtual bool IsDestroy { get { return gameObject == null; } }
        public virtual void Destroy() { }
        public abstract bool Excute(float dt);
        public virtual void DoPingPong() { }

        public void LoopInit()
        {
            _dt = 0;
        }
        public void PingPongInit()
        {
            DoPingPong();
            _dt = 0;
        }
    }
}